#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int> mapv;
struct Cmp
{
    bool operator()(const mapv& kv1, const mapv& kv2)
    {
        return kv1.second < kv2.second || (kv1.second == kv2.second && kv1.first < kv2.first);
    }
};
int main()
{
    int count, num, lie;
    map<int, int> Hashmap;
    cin >> count;
    for (int i = 0;i < count;i++)
    {
        cin >> lie;
        for (int j = 0;j < lie;j++)
        {
            cin >> num;
            Hashmap[num]++;
        }
    }
    vector<mapv> ans(Hashmap.begin(),Hashmap.end());
    sort(ans.begin(), ans.end(), Cmp());
    vector<mapv>::iterator it = ans.end();
    it--;
    cout << it->first << endl;
}
